<?php
CUserAuth::hasAccess(RECHT_FILIALE_UEBERWACHEN);;
/** costumer_view.php
 * Project name: project_name
 * Created on: 20.11.2011
 * Author: Matias Thomsen
 * 
 * Kunden auswahl aus einer Tabelle und Detailanzeige der Auswahl
 */

//-----INCLUDES---------
    include_once 'class/customer/CCustomerMapper.php';
//-----INCLUDES END-----
    $db = new CCustomerMapper($connArgs);
    
//-----VARS-------------
    $staff = $_SESSION['userID']; //employee logged in
    $gstelle = $_SESSION['gstelleId']; //employees' workstation
    $stelle = $db->getStelle($staff);
    $showCustomerData = true;
    $showCustomerTable = true;
//-----VARS END---------

    
//---------------------------------------
//-----TABLE WITH SELECTED CUSTOMER------
//---------------------------------------
    if ( isset($_GET['kunden-nr']) && $showCustomerData == true ){
            $customer = $db->getSingleCustomer($_GET['kunden-nr'], 0);

            if ( $customer != false ){
            ?>
                    <div class="form-costumer-create">
                        <div class="form-costumer-create-2cols">
                            <div class="show-customer-data-headline"><?php 
                                echo $customer->getAnrede()." ";
                                if ( $customer->getTitel() == "Prof_dr"){
                                    echo "Prof. Dr. ";
                                }  elseif ( $customer->getTitel() == "Dr" ) {
                                    echo "Dr. ";
                                }  elseif ( $customer->getTitel() == "Prof" ) {
                                    echo "Prof. ";
                                }
                                echo $customer->getName()." ";
                                echo $customer->getNachname();
                                if ( $customer->getGeburtsname() != "" ){
                                    echo " (geb.: ".$customer->getGeburtsname().")";
                                }
                                if ( $customer->getBearbeiterName() != "" ){
                                    echo " - Zuletzt bearbeitet von: ".$customer->getBearbeiterName();
                                }
                                if ( $customer->getFreigeberName() != "" ){
                                    echo " - Freigegeben von: ".$customer->getFreigeberName();
                                }

                          ?></div>
                            <!--####################################################################-->
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Geschäftsstelle</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getGstelleBezeichnung() ?></div>
                                <div class="clear"></div>
                            </div>
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Betreuer</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getBetreuerName() ?></div>
                                <div class="clear"></div>
                            </div>
                            <!--####################################################################-->
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Kunden Nummer</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getKundenNr() ?></div>
                                <div class="clear"></div>
                            </div>
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Status</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getStatus() ?></div>
                                <div class="clear"></div>
                            </div>
                            <!--####################################################################-->
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Straße, Hausnummer</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getStrasse_nr() ?></div>
                                <div class="clear"></div>
                            </div>
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Plz, Ort</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getPlz() ?>,&nbsp;<?= $customer->getOrt() ?></div>
                                <div class="clear"></div>
                            </div>
                            <!--####################################################################-->
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Wohnhaft seit</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getWohnhaftSeit() ?></div>
                                <div class="clear"></div>
                            </div>
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Wohnsituation</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getWohnsituation() ?></div>
                                <div class="clear"></div>
                            </div>
                            <!--####################################################################-->
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Geburtsdatum</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getGeburtsdatum() ?></div>
                                <div class="clear"></div>
                            </div>
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Familienstand</div>
                                <div class="form-customer-create-input"><?php
                                    if ( $customer->getFamilienstand() == "1"){
                                        echo "Ledig";
                                    }  elseif ( $customer->getFamilienstand() == "2" ) {
                                        echo "Verheiratet";
                                    }  elseif ( $customer->getFamilienstand() == "3" ) {
                                        echo "Geschieden";
                                    }  elseif ( $customer->getFamilienstand() == "4" ) {
                                        echo "Zusammenlebend";
                                    }  elseif ( $customer->getFamilienstand() == "5" ) {
                                        echo "Getrennt Lebend";
                                    }  elseif ( $customer->getFamilienstand() == "6" ) {
                                        echo "Verwitwet";
                                    }  else {
                                        echo "Unbekannt";
                                    }
                              ?></div>
                                <div class="clear"></div>
                            </div>
                            <!--####################################################################-->
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Staatsangehörigkeit</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getStaatsange() ?></div>
                                <div class="clear"></div>
                            </div>
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">E-Mail</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getEmail() ?></div>
                                <div class="clear"></div>
                            </div>
                            <!--####################################################################-->
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Telefonnummer 1</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getTelefon_1() ?></div>
                                <div class="clear"></div>
                            </div>
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Telefonnummer 2</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getTelefon_2() ?></div>
                                <div class="clear"></div>
                            </div>
                            <!--####################################################################-->
                            <div class="show-customer-data-headline">Zusatz angaben</div>
                            <!--####################################################################-->
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Monatseinkommen</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getMonatEinkommen() ?></div>
                                <div class="clear"></div>
                            </div>
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Extra Einkommen</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getExtraEinkommen() ?></div>
                                <div class="clear"></div>
                            </div>
                            <!--####################################################################-->
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Berufsgruppe</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getBerufsgruppe() ?></div>
                                <div class="clear"></div>
                            </div>
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Branchen</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getBranche() ?></div>
                                <div class="clear"></div>
                            </div>
                            <!--####################################################################-->
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Beruf</div>
                                <div class="form-customer-create-input">&nbsp;<?= $customer->getBeruf() ?></div>
                                <div class="clear"></div>
                            </div>
                            <div class="form-customer-create-input-wrap">
                                <div class="form-customer-create-label">Datenschutzbedingung</div>
                                <div class="form-customer-create-input"><?php
                                    if ( $customer->getDatenschutz() == "1"){
                                        echo "akzeptiert";
                                    }  else {
                                        echo "nicht akzeptiert";
                                    }
                              ?></div>
                                <div class="clear"></div>
                            </div>
                            <!--####################################################################-->

                        </div>
                    </div>
    <?php
                } //if ( $customer != 0 ){ ENDS
        }//if ( isset($_GET['kunden-nr']) ){ ENDS
        
        
//---------------------------------------
//-----TABLE WITH SELECTED CUSTOMER END--
//---------------------------------------
    
//---------------------------------------
//-----TABLE WITH CUSTOMERS--------------
//---------------------------------------
if ( $showCustomerTable ){;
    $action = array("filiale");
    $customers = $db->getCustomers("filiale", $staff, $stelle);//get/select all active customers
    include_once("customer_table.php");
}
//---------------------------------------
//-----TABLE WITH CUSTOMERS END----------
//---------------------------------------

?>